home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #2 / Monster Media No. 2 (Monster Media)(1994).ISO / prog_gen / xv_pc16a.zip / HOTKEYS.INC < prev    next >
Text File  |  1994-04-20  |  2KB  |  75 lines

  1. {
  2. Accelerator keys for the XView-PC interface
  3. By Antonio Carlos Moreirao de Queiroz - acmq@coe.ufrj.br
  4. Version 1.0 - 10/04/94
  5.  
  6. This procedure implements a system of "accelerator keys" using the
  7. "interposer". The mouse will move to the center of the first object
  8. in the screen that has in its "xv_label" the letter pressed along
  9. with the "Alt" key, in upper case. The selected window becomes the
  10. active window. Buttons are pressed, textfields put in edition mode,
  11. and menus are opened.
  12. To install:
  13. Include this file, and insert after "xv_init": interposer:=HotKeys;
  14. The program must use the units Mickey and XView.
  15. }
  16.  
  17. {$I extkeys.inc}
  18.  
  19. {$F+}
  20.  
  21. PROCEDURE HotKeys;
  22. VAR
  23.   ptw,pto:Xv_opaque;
  24.   found:BOOLEAN;
  25.   pt:INTEGER;
  26. CONST
  27.   table:ARRAY[0..35] OF INTEGER=(
  28.     kAltA,kAltB,kAltC,kAltD,KAltE,
  29.     kAltF,kAltG,kAltH,kAltI,kAltJ,
  30.     kAltK,kAltL,kAltM,kAltN,kAltO,
  31.     kAltP,kAltQ,kAltR,kAltS,kAltT,
  32.     kAltU,kAltV,kAltW,kAltX,kAltY,kAltZ,
  33.     kAlt0,kAlt1,kAlt2,kAlt3,kAlt4,
  34.     kAlt5,kAlt6,kAlt7,kAlt8,kAlt9
  35.   );
  36.  
  37. BEGIN
  38.   IF (ie_code>2000) THEN BEGIN
  39.     pt:=0; found:=FALSE;
  40.     REPEAT
  41.       IF table[pt]=ie_code THEN found:=TRUE
  42.       ELSE inc(pt)
  43.     UNTIL found or (pt>35);
  44.     IF not found THEN Exit;
  45.     IF pt>25 THEN inc(pt,Ord('0')-26) ELSE inc(pt,Ord('A'));
  46.     found:=FALSE;
  47.     ptw:=active_w;
  48.     REPEAT
  49.       pto:=ptw;
  50.       REPEAT
  51.         IF pos(Chr(pt),pto^.xv_label)<>0 THEN found:=TRUE
  52.         ELSE pto:=pto^.next
  53.       UNTIL found or (pto=nil);
  54.       IF not found THEN ptw:=ptw^.under;
  55.     UNTIL found or (ptw=active_w);
  56.     IF found THEN BEGIN
  57.       cursor_off;
  58.       open_window(ptw);
  59.       IF pto^.o_type=frame THEN BEGIN
  60.         mousex:=ptw^.x+ptw^.dx div 2;
  61.         mousey:=ptw^.y+mrgy div 2;
  62.       END
  63.       ELSE BEGIN
  64.         mousex:=ptw^.x+mrgx+pto^.x+pto^.dx div 2;
  65.         mousey:=ptw^.y+mrgy+pto^.y+pto^.dy div 2;
  66.       END;
  67.       mouse_move(mousex,mousey);
  68.       IF pto^.menu_name<>nil THEN menu_show(pto^.menu_name);
  69.       IF (pto^.o_type=button) or (pto^.o_type=textfield) THEN ie_code:=MS_LEFT;
  70.     END
  71.   END
  72. END;
  73.  
  74. {$F-}
  75.